//
//  BaseTableViewController.swift
//  WBDemo
//
//  Created by Jin on 17/04/2018.
//  Copyright © 2018 com.baidu.123. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController {

    var login:Bool = UserAccount.login()
    var visitorView:VisitorView?
     
    override func loadView() {
        super.loadView()
        
        login ? super.loadView() : setupVisitorView()
    }

    // MARK: - 内部控制方法
    private func setupVisitorView(){
        visitorView = VisitorView.visitorView()
        view = visitorView
        
        visitorView?.registerBtn.addTarget(self, action: #selector(registerBtnClick), for: UIControlEvents.touchUpInside)
        visitorView?.loginBtn.addTarget(self, action: #selector(loginBtnClick), for: UIControlEvents.touchUpInside)
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.plain, target: self, action: #selector(registerBtnClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.plain, target: self, action: #selector(loginBtnClick))
        
//        let titleButton = UIButton()
//        titleButton.setTitleColor(.black, for: .normal)
//        titleButton.setTitle("二哈哈", for: UIControlState.normal)
//        navigationItem.titleView = titleButton
    }
    
    @objc private func registerBtnClick(){
        JLog(message: "注册按钮")
    }
    
    @objc private func loginBtnClick(){
        let sb = UIStoryboard(name: "OAuthViewController", bundle: nil)
        let OAuthVc = sb.instantiateInitialViewController()
        
//        let OAuthVc = TempViewController()
        present(OAuthVc!, animated: true, completion: nil)
    }
}
